home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group98c.txt
/
000033_icon-group-sender _Wed Sep 16 12:36:10 1998.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
5KB
Return-Path: <icon-group-sender>
Received: from kingfisher.CS.Arizona.EDU (kingfisher.CS.Arizona.EDU [192.12.69.239])
by baskerville.CS.Arizona.EDU (8.9.1a/8.9.1) with SMTP id MAA02192
for <icon-group-addresses@baskerville.CS.Arizona.EDU>; Wed, 16 Sep 1998 12:36:09 -0700 (MST)
Received: by kingfisher.CS.Arizona.EDU (5.65v4.0/1.1.8.2/08Nov94-0446PM)
id AA05198; Wed, 16 Sep 1998 12:35:41 -0700
Date: Wed, 16 Sep 1998 09:42:26 -0700
From: swampler@noao.edu (Steve Wampler)
Subject: Re: Context Switching
To: icon-group@optima.CS.Arizona.EDU
Message-Id: <swampler-9808161642.AA000619813@orpheus.gemini.edu>
In-Reply-To: <35FF1A94.66F1@gte.net>
Errors-To: icon-group-errors@optima.CS.Arizona.EDU
Status: RO
MJE wrote:
> If you want a language that can do a lot more than C, then why rely all
> the time on C conventions, instead of making your own?
Performance and effort.
> Icon is wonderful with strings because the strings are not C strings,
> they are Icon objects. Analogy: Icon can be wonderful with stacks,
> because the stacks are not C stacks, but Icon stacks.
True, but most hardware has pretty direct support of C-style stacks,
unless you design very carefully, it's easy to lose performance when
you adopt other approaches.
> Icon has complete control of how it handles functions, coexpressions,
> recursion, and so on, there is no mandatory requirement that they all be
> treated as C function calls. Icon doesn't have to put parameters on a
> stack, it can put them on the heap and "context-switch" by switching
> data pointers to blocks on the heap. You could implement several
> "stack" structures right on the heap, instead of relying on the system
> stack.
Unless thinks have changed a lot since co-expressions were originally
implemented, this is already exactly how Icon implements co-expressions -
multiple heap-based stacks. This is also why you see co-expression
stack overflow related errors - heap-based stacks are difficult to
implement w/o the hardware support given to the system stack. As an
historical aside, the original co-expression implementation did not
have this problem, but only because of hardware support for user stacks
on the PDP-11 class machines - highly non-portable.
> Those heap-based stacks would handle all the issues involved in
> context-switching, without resorting to fancy thread systems.
Agreed, but for the most part, heap-based stacks are (were?) how
co-expressions are implemented - to get the rest of the functionality
you (and most of the rest of us) would like is a *major* rewrite of
the implementation, see below.
> Built-in operators and functions can easily be rewritten to assume that
> their stack exists elsewhere. I.e., as C calls, they take no input
> parameters, but instead lookup a global pointer that gives them their
> current stack somewhere on the heap, then they take parameters from
> that.
Well, you shouldn't think in terms of a stack at this point, you
have a general call graph now - each context (function, etc.) would
have a node in the call graph for each invocation instance. Using
heap based stacks is what Icon has now, but usually implemented to
be efficient by using C-style stack access conventions.
The 'functionally correct' way to implement Icon would be to go to
what could be called an object-based implementation - each context
would exist as an object in the heap. It is very hard to implement
this efficiently, however, and the original implementation represented a
trade between portability and efficiency.
> Or, rather than rewriting the builtins, you just wrap them with
> "handlers" that know about these things and put the right parameters
> into the standard C function calls. So, none of the built-ins change,
> but you add "handlers" to baby-sit them with respect to the switching
> stacks.
>
> The idea of "fooling" the Icon executable, and doing so in a way that is
> non-portable, assembler-based, and buggy, and that will break with every
> vendor's compiler release, is what I dislike.
>
> I just wanted to share these ideas. Maybe I haven't really knocked down
> your points, but that's OK, we share ideas here.
A *long* ago I thought about an object-based implementation for co-expressions
(more precisely for *all* context switching in Icon (a function call is also
a context switch)) - since that's really what is needed for this approach to
work). Mark is correct, it can be made to work, but it isn't easy to
implement both correctly and efficiently.
Personally, I would enjoy seeing such an implementation of Icon - it
would be an interesting experiment to watch. It would not be a trivial
undertaking and I suspect the Icon-project has enough to do already, so
someone else would probably have to take the initiative.
--
Steve Wampler - swampler@gemini.edu [Gemini 8m Telescopes Project (under AURA)]
The gods that smiled at your birth are now laughing openly. (Fortune Cookie)